/**
 * Created by wuye on 2017/12/11.
 */


var setting = {
    data: {
        simpleData: {
            enable: true,
            idKey: "deptId",
            pIdKey: "parentId",
            rootPId: -1
        },
        key: {
            url:"nourl"
        },

    }
};
var ztree;

var vm = new Vue({
    el:'#rrapp',
    data:{
        book:{},
    },
    created:function () {
        var obj=this.change(window.location.search)
        if(obj.id){
            this.getBook(obj.id)
        }
    },
    filters:{
        pic: function(value) {
            if (
                value.backgroundImage === "url(undefined)" ||
                value.backgroundImage == "url()" ||
                value.backgroundImage == "url(null)"||
                value.backgroundImage == "url(/styles/images/book/no-pic.jpg)"
            )
                return { backgroundImage: "url(../../img/zanwu.png" };
            return value;
        },
    },
    methods: {
        // 获取路由ID
        change:function(str) {
            if(str == undefined) return
            str = str.substr(1)
            var arr = str.split("&"),
                obj = {},
                newArr = []
            arr.map(function(value,index,arr){
                newArr = value.split("=")
                if(newArr[0] != undefined) {
                    obj[newArr[0]] = newArr[1]
                }
            })
            return obj
        },
        getBook: function (id) {
            $.get(baseURL + "sys/book/findById/" + id, function (r) {
                console.log(r)
                vm.book = r.book;
            });
        },
        back:function () {
            window.history.go(-1)
        },
    }
});
